let request = new XMLHttpRequest();
request.open('GET', 'https://restcountries.eu/rest/v2/lang/es', true);
request.onload = function () {

  const array          = JSON.parse(this.response);
  let countryModalLoop = document.querySelector('.country-modal');
  let countryLoop      = document.querySelector('.country-container');
  let item = 0;

  array.forEach(function(obj){

    /* populate array in home */
    countryLoop.insertAdjacentHTML('beforeend',
                                   countryItem(obj,
                                               item));

    /* modal */
    countryModalLoop.insertAdjacentHTML('beforeend',
                                        countryModal(obj,
                                                     basicsTable(obj),
                                                     translationTable(obj.translations),
                                                     item));

    /* set click gestures */
    clickGestures(item);
    item++;
  });
};

request.send();
